package com.sinitek.web.response;

import com.sinitek.enums.ApiResultEnum;

/**
 * @program: elastic
 * @description: Api响应结果
 * @author: Mr.chen
 * @create: 2019-04-24 12:55
 */
public class R {
    /**
     * 成功且带数据
     **/
    public static ApiResult success(Object object) {
        ApiResult result = new ApiResult();
        result.setCode(ApiResultEnum.SUCCESS.getCode());
        result.setMsg(ApiResultEnum.SUCCESS.getMsg());
        result.setData(object);
        return result;
    }

    /**
     * 成功但不带数据
     **/
    public static ApiResult success() {
        return success(null);
    }

    /**
     * 失败
     **/
    public static ApiResult error(Integer code, String msg) {
        ApiResult result = new ApiResult();
        result.setCode(code);
        result.setMsg(msg);
        result.setData(null);
        return result;
    }
}
